// SKU模块接口管理

import request from '@/utils/request.ts'
import { SkuInfo, SkuResponseData } from '@/api/product/sku/type.ts'

enum API {
  // 获取已有的商品数据-SKU
  SKU_URL = '/admin/product/list/',
  // 上架
  ON_SALE_URL = '/admin/product/onSale/{skuId}',
  //下架
  CANCEL_SALE_URL = '/admin/product/cancelSale/{skuId}',
  // 获取商品详情的接口
  SKU_INFO_URL = '/admin/product/getSpuInfo/{spuId}',
  // 删除已有的商品
  DELETE_SKU_URL = '/admin/product/deleteSku/{skuId}',
}

// 获取商品SKU的接口
export const reqSkuList = (page: number, limit: number) =>
  request.get<any, SkuResponseData>(API.SKU_URL + `${page}/${limit}`)
// 上架
export const reqOnSale = (skuId: number) =>
  request.get<any, any>(API.ON_SALE_URL.replace('{skuId}', skuId.toString()))
// 下架
export const reqCancelSale = (skuId: number) =>
  request.get<any, any>(
    API.CANCEL_SALE_URL.replace('{skuId}', skuId.toString()),
  )
// 获取商品详情的接口
export const reqSkuInfo = (spuId: number) =>
  request.get<any, SkuInfo>(
    API.SKU_INFO_URL.replace('{spuId}', spuId.toString()),
  )
// 删除已有的商品
export const reqDeleteSku = (skuId: number) =>
  request.delete<any, any>(
    API.DELETE_SKU_URL.replace('{skuId}', skuId.toString()),
  )
